<template>
  <TextSetting
    :data="data"
    :disabled="disabled"
    show-placeholder
    show-default-value
    :default-value-type="type"
    :default-value-limit="type === 'textarea'"
  />
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'
import { WidgetType } from '@/types'
import { Widget } from '@/models'
import TextSetting from './TextSetting.vue'

export default defineComponent({
  name: 'FaInputSetting',

  components: { TextSetting },

  props: {
    /** 控件数据 */
    data: {
      type: Widget,
      required: true
    },

    /** 是否禁用 */
    disabled: {
      type: Boolean,
      default: false
    }
  },

  setup(props) {
    return {
      type: computed(() => (props.data.type === WidgetType.TEXTAREA ? 'textarea' : 'text'))
    }
  }
})
</script>
